package com.ruoyi.consumer.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.consumer.domain.CDeviceOrders;
import com.ruoyi.consumer.service.ICDeviceOrdersService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 实时业务实际订单Controller
 * 
 * @author YFENTEST
 * @date 2023-11-30
 */
@RestController
@RequestMapping("/consumer/deviceOrder")
public class CDeviceOrdersController extends BaseController
{
    @Autowired
    private ICDeviceOrdersService cDeviceOrdersService;

    /**
     * 查询实时业务实际订单列表
     */
    @PreAuthorize("@ss.hasPermi('consumer:deviceOrder:list')")
    @GetMapping("/list")
    public TableDataInfo list(CDeviceOrders cDeviceOrders)
    {
        startPage();
        List<CDeviceOrders> list = cDeviceOrdersService.selectCDeviceOrdersList(cDeviceOrders);
        return getDataTable(list);
    }

    /**
     * 导出实时业务实际订单列表
     */
    @PreAuthorize("@ss.hasPermi('consumer:deviceOrder:export')")
    @Log(title = "实时业务实际订单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CDeviceOrders cDeviceOrders)
    {
        List<CDeviceOrders> list = cDeviceOrdersService.selectCDeviceOrdersList(cDeviceOrders);
        ExcelUtil<CDeviceOrders> util = new ExcelUtil<CDeviceOrders>(CDeviceOrders.class);
        util.exportExcel(response, list, "实时业务实际订单数据");
    }

    /**
     * 获取实时业务实际订单详细信息
     */
    @PreAuthorize("@ss.hasPermi('consumer:deviceOrder:query')")
    @GetMapping(value = "/{deviceOrderId}")
    public AjaxResult getInfo(@PathVariable("deviceOrderId") Integer deviceOrderId)
    {
        return success(cDeviceOrdersService.selectCDeviceOrdersByDeviceOrderId(deviceOrderId));
    }

    /**
     * 新增实时业务实际订单
     */
    @PreAuthorize("@ss.hasPermi('consumer:deviceOrder:add')")
    @Log(title = "实时业务实际订单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CDeviceOrders cDeviceOrders)
    {
        return toAjax(cDeviceOrdersService.insertCDeviceOrders(cDeviceOrders));
    }

    /**
     * 修改实时业务实际订单
     */
    @PreAuthorize("@ss.hasPermi('consumer:deviceOrder:edit')")
    @Log(title = "实时业务实际订单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CDeviceOrders cDeviceOrders)
    {
        return toAjax(cDeviceOrdersService.updateCDeviceOrders(cDeviceOrders));
    }

    /**
     * 删除实时业务实际订单
     */
    @PreAuthorize("@ss.hasPermi('consumer:deviceOrder:remove')")
    @Log(title = "实时业务实际订单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{deviceOrderIds}")
    public AjaxResult remove(@PathVariable Integer[] deviceOrderIds)
    {
        return toAjax(cDeviceOrdersService.deleteCDeviceOrdersByDeviceOrderIds(deviceOrderIds));
    }
}
